package com.geek.novel.entity

import com.geek.novel.utils.SnowIdUtil
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import io.realm.annotations.RealmClass
import java.util.*

@RealmClass
open class BookRead : RealmObject {
	
	constructor() : super()

	constructor(bookName: String) : super(){
		this.bookName = bookName
	}
	
	@PrimaryKey
	open var id: Long? = null
	
	open var bookId: String? = ""

	/**书名*/
	open var bookName: String? = ""

	/**作者ID*/
	open var authorId: String? = ""
	/**作者名*/
	open var authorName: String? = ""

	/**图片文件id*/
	open var imgId: String? = ""

	/**
	 * 书籍类型，如玄幻、科幻等
	 * 对应枚举BookCategory的值
	 */
	open var category: String? = ""
	open var categoryStr: String? = ""

	/**书籍描述*/
	open var bookDesc: String? = ""

	/**书籍状态(连载：0，完结：1)*/
	open var bookStatus: Int = 0

	/**
	 * 完本时间
	 */
	open var endTime: Date? = null

	/**字数*/
	open var wordCount: Long = 0

	/**点击数*/
	open var visitCount: Long = 0

	/**阅读数*/
	open var readCount: Long = 0

	/**总分数*/
	open var totalRate: Long? = 0
	/**评分人数*/
	open var rateCount: Long? = 0
	/**平均分数*/
	open var rate: String? = "0"

	/**是否启用*/
	open var status: Boolean = true
	
	/**
	 * 爬虫来源的id
	 */
	open var bookCrawlerId: Long? = null
	/**
	 * 爬虫来源的书本id,因为是网络爬取,这个id很可能是字符串
	 */
	open var crawlBookId: String? = null
	
	/**
	 * 最后一章的名称，用于展示
	 */
	open var lastIndexName: String? = null
	
	/**
	 * 最后一章更新时间
	 */
	open var lastIndexUpdateTime: Date? = null

	/**用户阅读的章节下标*/
	open var curReadIndex: Int = 0
	/**用户阅读的页码*/
	open var curSectionPage: Int = 0

	/**排序字段*/
	open var sort: Int = 0
	/**是否置顶*/
	open var top: Boolean = false

	/**是否加入书架*/
	open var collect: Boolean = false

	/**是否是本地书籍*/
	open var local: Boolean = false


	fun initEntity(){
		this.id = SnowIdUtil.getInstance().nextId()
	}
}